package com.hspedu.properties_;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author DL5O
 * @version 1.0
 */
public class Properties01 {
    public static void main(String[] args) throws IOException {
        /*//读取MySql.properties文件并获取ip，user和pwd
        String filePath = "src\\mysql.properties";
        BufferedReader br = new BufferedReader(new FileReader(filePath));
        String line ="";
        while((line = br.readLine()) != null){
//            System.out.println(line);
            String[] split = line.split("=");//根据等号来拆分
            System.out.println(split[0] + "值是:" + split[1]);
        }
        br.close();*/

        String filePath = "src\\mysql.properties";
        BufferedReader br = new BufferedReader(new FileReader(filePath));
        String s = "";
        while((s = br.readLine()) != null){
            //如果指定要求只获得ip
            String[] split = s.split("=");
            if(split[0].equals("ip")) {
                System.out.println(split[0] + "值是:" + split[1]);
                break;
            }
        }
        br.close();
    }
}
